package com.tj.seed.common.jwt;

import com.auth0.jwt.algorithms.Algorithm;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JwtConfig {
    @Value("${tj.jwt.secret}")
    private String secret;
    @Value("${tj.jwt.issuer}")
    private String issuer;

    @Bean
    public Algorithm getAlgorithm() {
        return Algorithm.HMAC512(secret);
    }

    @Bean
    public TokenParser tokenParser() {
        return new TokenParserImpl(getAlgorithm(), issuer);
    }

    @Bean
    public TokenGenerator tokenGenerator() {
        return new TokenGeneratorImpl(getAlgorithm(), issuer);
    }
}
